package ibmetp.mis.tags;

import ibmetp.mis.common.Constants;
import ibmetp.mis.dao.SysParamDao;
import ibmetp.mis.vo.SysParam;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

public class ParamTag extends TagSupport {
	private String key;
	private String category;
	@Override
	public int doEndTag() throws JspException {
			
		SysParamDao spd=new  SysParamDao();
		SysParam sp=new SysParam();
		sp.setSysparamName(key);
		//sp.setSysparamName(category);
		System.out.println(key);
		System.out.println(category);
		if(spd.getSysParamPage(1,3,sp).getTotal()>0)
		sp=(SysParam)spd.getSysParamPage(1, 1,sp).getList().get(0);
		else if(key.equals("SYSTEM_NAME"))//系统必须有的
		  sp.setValue(Constants.SYSTEM_NAME);
		else sp.setValue(Constants.PARAM_NO_EXISTS);
		try {
			this.pageContext.getOut().print(sp.getValue());
		} catch (Exception e) {
			e.printStackTrace();
		}
       
		return EVAL_PAGE;
	}
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public String getCategory() {
		return category;
	}
	public void setCategory(String category) {
		this.category = category;
	}
    
}
